package com.mrjy.integral.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrjy.common.entity.IntegralExchangedLog;
import com.mrjy.integral.bo.IIntegralExchangedLogBo;
import com.mrjy.integral.dto.IntegralExchangedLogDTO;
import com.mrjy.integral.dto.IntegralExchangedOrderDTO;

/**
 * 积分兑换记录
 * @author Administrator
 *
 */

@Controller
@RequestMapping("/integral/integralExchangedLog")
public class IntegralExchangedLogController {
	
	@Resource
	private IIntegralExchangedLogBo integralExchangedLogBo;
	
	/**
	 * for weixin
	 * 查询用户卡券(实物+代金券) 支持分页
	 * @param exchangedLog
	 * @return
	 */
	@RequestMapping("/queryByUserId")
	@ResponseBody
	public Object queryByUserId(IntegralExchangedLogDTO dto,HttpSession session){
		return integralExchangedLogBo.queryByUserId(dto,session);
	}
	
	/**
	 * for weixin
	 * 成长-卡券-详情
	 * 查询卡券详情 传卡券id
	 * @param exchangedLog
	 * @param session
	 * @return
	 */
	@RequestMapping("/queryIEDetail")
	@ResponseBody
	public Object queryIEDetail(IntegralExchangedLog exchangedLog,HttpSession session){
		return integralExchangedLogBo.queryIEDetail(exchangedLog,session);
	}
	
	/**
	 * 兑换
	 * @param dto
	 * @param session
	 * @return
	 */
	@RequestMapping("/doExchange")
	@ResponseBody
	public Object doExchange(IntegralExchangedLogDTO dto,HttpSession session){
		return integralExchangedLogBo.txInsert(dto,session);
	}
	
	/**
	 * 提交收件信息
	 * @param dto
	 * @param session
	 * @return
	 */
	@RequestMapping("/submitReceiptInfo")
	@ResponseBody
	public Object submitReceiptInfo(IntegralExchangedLogDTO dto,HttpSession session){
		return integralExchangedLogBo.txUpdate(dto,session);
	}
	
	/**
	 * for back
	 * 后台查询兑换日志列表 支持分页
	 * @param exchangedLog
	 * @param session
	 * @return
	 */
	@RequestMapping("/queryPageForBack")
	@ResponseBody
	public Object queryPageForBack(IntegralExchangedLogDTO dto,HttpSession session){
		return integralExchangedLogBo.queryPageForBack(dto,session);
	}
	
	/**
	 * for back
	 * 后台查询代金券消费日志 支持分页
	 * @param dto
	 * @param session
	 * @return
	 */
	@RequestMapping("/queryPageUsedForBack")
	@ResponseBody
	public Object queryPageUsedForBack(IntegralExchangedOrderDTO dto,HttpSession session){
		return integralExchangedLogBo.queryPageUsedForBack(dto,session);
	}
	
	/**
	 * 启用,禁用
	 * @param exchangedLog
	 * @param session
	 * @return
	 */
	@RequestMapping("/updateDisableFlag")
	@ResponseBody
	public Object updateDisableFlag(IntegralExchangedLog exchangedLog,HttpSession session){
		return integralExchangedLogBo.updateDisableFlag(exchangedLog,session);
	}
	
	/**
	 * 邮寄
	 * @param exchangedLog
	 * @param session
	 * @return
	 */
	@RequestMapping("/doPost")
	@ResponseBody
	public Object doPost(IntegralExchangedLog exchangedLog,HttpSession session){
		return integralExchangedLogBo.doPost(exchangedLog,session);
	}
	
	/**
	 * 导出兑换日志
	 * @param dto
	 * @param session
	 * @return
	 */
	@RequestMapping("/export")
	@ResponseBody
	public Object export(IntegralExchangedOrderDTO dto,HttpSession session,HttpServletResponse response){
		return integralExchangedLogBo.export(dto,session,response);
	}
	
	/**
	 * 导出代金券消费日志
	 * @param dto
	 * @param session
	 * @param response
	 * @return
	 */
	@RequestMapping("/exportUsed")
	@ResponseBody
	public Object exportUsed(IntegralExchangedOrderDTO dto,HttpSession session,HttpServletResponse response){
		return integralExchangedLogBo.exportUsed(dto,session,response);
	}
}
